package com.example.sneakerappserver.util;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;

public class ImageUtils {
    public static byte[] imageToBytes(String imagePath) throws IOException {
        // 使用 ClassLoader 获取资源的输入流
        try (InputStream inputStream = ImageUtils.class.getClassLoader().getResourceAsStream(imagePath)) {
            if (inputStream == null) {
                throw new IOException("Image not found: " + imagePath);
            }
            return inputStream.readAllBytes();
        }
    }
}
